<template>
  <!-- 大小额贷记退汇审核-->
  <el-dialog :title="title" center :visible.sync="openState" width="1024px" :close-on-click-modal="false">
    <el-form ref="queryDetail" :model="form" label-width="110px">
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>交易基础信息</span>
        </div>
        <el-row>
          <el-col :span="8">
            <el-form-item label="交易流水号" prop="id">
              <el-input v-model="form.id" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="原交易流水号" prop="oriid">
              <el-input v-model="form.oriid" disabled/>
            </el-form-item>
          </el-col>

          <el-col :span="8">
            <el-form-item label="CPG日期" prop="oriworkdate">
              <el-date-picker v-model="form.oriworkdate" style="width: 100%" type="date" value-format="yyyyMMdd" disabled/>
            </el-form-item>
          </el-col>

        </el-row>
        <el-row>
          <el-col :span="8">
            <el-form-item label="工作日期" prop="vdate">
              <el-date-picker v-model="form.vdate" style="width: 100%" type="date" value-format="yyyyMMdd" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务类型" prop="oribizTypeCode">
              <el-select
                style="width: 100%"
                v-model="
                  form.oribizTypeCode === null || form.oribizTypeCode === undefined
                    ? ''
                    : form.oribizTypeCode + '-' + form.oribizTypeCodeDesc
                "
                placeholder="业务类型"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="业务种类" prop="oribizCtgyCode">
              <el-select
                style="width: 100%"
                v-model="
                  form.oribizCtgyCode === null || form.oribizCtgyCode === undefined
                    ? ''
                    : form.oribizCtgyCode + '-' + form.oribizCtgyCodeDesc
                "
                placeholder="业务种类"
                :disabled="true"
              ></el-select>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="8" v-show="this.form.orisyscode==='HVPS'">
            <el-form-item label="业务优先级" prop="oribizProity">
              <el-select style="width: 100%;" v-model="form.oribizProity" placeholder="业务优先级" disabled>
                <el-option
                  v-for="dict in dictMap.PRIORITY3CODE"
                  :key="dict.value"
                  :label="`${dict.value}-${dict.text}`"
                  :value="dict.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>
          <el-col :span="8">
            <el-form-item label="交易币种" prop="oricurcd">
              <el-input v-model="form.oricurcd" placeholder="货币种类" :disabled="true"   disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="金额" prop="oriamount">
              <ht-amount-input v-model="form.oriamount" placeholder="交易金额"  :disable="true"></ht-amount-input>
            </el-form-item>
          </el-col>
          <el-col :span="8">
            <el-form-item label="大写金额" prop="bAmount">
              <ht-amount-upper :inputValue="form.oriamount" placeholder="交易金额" ></ht-amount-upper>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-row>
            <el-col :span="24">
              <el-form-item label="退汇原因" prop="txRemarks">
                <el-input type="textarea" v-model="form.txRemarks" disabled/>
              </el-form-item>
            </el-col>
          </el-row>
        </el-row>
      </el-card>

      <!--付款人信息-->
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>付款人信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="付款人账号" prop="oripayerActno">
              <el-input v-model="form.oripayerActno" placeholder="付款人账号" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="付款行行号" prop="oripayerBrno">
              <el-input v-model="form.oripayerBrno" placeholder="付款行行号" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-form-item label="付款人名称" prop="oripayerName">
            <el-input v-model="form.oripayerName" placeholder="付款人名称" disabled/>
          </el-form-item>
        </el-row>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-oripayer">
              <el-form-item label="付款人开户行号" prop="oripayerAccBrno">
                <el-input v-model="form.oripayerAccBrno" placeholder="付款人开户行行号" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="付款人开户行行名" prop="oripayerAccBrname" label-width="130px">
              <el-input v-model="form.oripayerAccBrname" placeholder="付款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>

      <!--收款人信息-->
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>收款人信息</span>
        </div>
        <el-row :gutter="10">
          <el-col :span="12">
            <el-form-item label="收款人账号" prop="oripayeeActno">
              <el-input v-model="form.oripayeeActno" placeholder="收款人账号" disabled/>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="收款行行号" prop="oripayeeBrno">
              <el-input v-model="form.oripayeeBrno" placeholder="收款行行号" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
        <el-form-item label="收款人名称" prop="oripayeeName">
          <el-input v-model="form.oripayeeName" placeholder="收款人名称" disabled/>
        </el-form-item>
        <el-row :gutter="10">
          <el-col :span="8">
            <div class="grid-oripayee">
              <el-form-item label="收款人开户行号" prop="oripayeeAccBrno">
                <el-input v-model="form.oripayeeAccBrno" placeholder="收款人开户行行号" disabled/>
              </el-form-item>
            </div>
          </el-col>
          <el-col :span="16">
            <el-form-item label="收款人开户行行名" prop="oripayeeAccBrname" label-width="130px">
              <el-input v-model="form.oripayeeAccBrname" placeholder="收款人开户行行名" disabled/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
      <el-card class="form-card">
        <div slot="header" class="label-header-msg">
          <span>其他信息</span>
        </div>

        <el-row>
          <el-col :span="12">
            <el-form-item label="录入操作员" prop="mdTlrno">
              <el-input v-model="form.mdTlrno" :disabled="true" />
            </el-form-item>
          </el-col>

          <el-col :span="12">
            <el-form-item label="录入时间" prop="mdTime">
              <el-date-picker
                style="width: 100%"
                v-model="form.mdTime"
                value-format="yyyyMMddHHmmss"
                type="datetime"
                :disabled="true"
              />
            </el-form-item>
          </el-col>
        </el-row>

        <el-row>

          <el-col :span="24">
            <el-form-item label="审核附言" prop="audRemarks">
              <el-input type="textarea" v-model="form.audRemarks" maxlength="128" show-word-limit/>
            </el-form-item>
          </el-col>
        </el-row>
      </el-card>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button type="primary" @click="approve">审核</el-button>
      <el-button type="danger" @click="reject">拒绝</el-button>
      <el-button @click="cancel">关闭</el-button>
    </div>
  </el-dialog>
</template>
<script>
import {detail, approve, reject} from "@/api/cnaps/baseBiz/return/check";
import HtAmountInput from "@/views/components/HtAmountInput";
import HtAmountUpper from "@/views/components/HtAmountUpper";


export default {
  name: "EditInfo",
  components: {
    HtAmountInput,
    HtAmountUpper,

  },
  props: {
    dictMap: {
      type: Object,
      default: () => {
        return {};
      },
    },
  },
  data() {
    return {
      cardList: [],
      busTypeList: [],
      id: "",
      title: "",
      msgType: "",
      // 是否显示弹出层
      openState: false,
      // 表单参数
      form: {},
    };
  },
  watch: {
    dictMap: {
      handler(data) {
      },
    },
  },
  async mounted() {
    let that = this;
  },
  methods: {
    // 表单重置
    reset() {
      // this.resetForm("editForm");
      this.$set(this, "form", {});
    },
    close() {
      this.openState = false;
    },
    // 关闭回掉
    handleClose(done) {
      this.$confirm("确认关闭？")
        .then((_) => {
          this.reset();
          done();
        })
        .catch((_) => {
        });
    },
    show(id = "") {
      let that = this;
      this.id = id;
      this.title = "大小额贷记退汇审核";
      if (id) {
        // 如果传了ID 这里查询一个已经存在的数据
        detail({
          id: this.id,
        }).then((res) => {
          let tempForm = res.result;
          this.$set(this, "form", tempForm);
          this.openState = true;
        });
      }
    },

    cancel() {
      this.openState = false;
      this.reset();
      this.$emit("editComplete", false);
    },

    /** TODO提交按钮 */
    approve: function () {
      let formData = this.form;
      // 表单数据没有pkgno,单独传入
      formData.pkgno = this.form.pkgno;
      //如果有ID 则是修改
      if (this.id) {
        formData.id = this.id;
        approve(formData).then((res) => {
          this.msgSuccess("审核成功");
          this.$emit("editComplete", true);
          this.openState = false;
        });
      }
    },
    reject() {
      let formData = this.form;
      formData.id = this.id;
      formData.pkgno = this.form.pkgno;
      reject(formData).then((res) => {
        this.msgSuccess("拒绝成功");
        this.$emit("editComplete", true);
        this.openState = false;
      });
    },
  },
};
</script>
<style>
.label-header-msg {
  font-weight: bold;
}

.form-card {
  margin-bottom: 10px;
}
</style>
